package app.xq.com.helloworldapp;

import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.design.widget.BottomNavigationView;
import android.support.v7.app.AppCompatActivity;
import android.view.MenuItem;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import app.xq.com.helloworldapp.adapter.AccountsListAdapter;

public class MainActivity extends AppCompatActivity {

    private TextView mTextMessage;

    private BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener
            = new BottomNavigationView.OnNavigationItemSelectedListener() {

        @Override
        public boolean onNavigationItemSelected(@NonNull MenuItem item) {
            switch (item.getItemId()) {
                case R.id.navigation_home:
//                    mTextMessage.setText(R.string.title_home);
                    return true;
                case R.id.navigation_dashboard:
//                    mTextMessage.setText(R.string.title_dashboard);
                    return true;
                case R.id.navigation_notifications:
//                    mTextMessage.setText(R.string.title_notifications);
                    return true;
            }
            return false;
        }
    };

    private List<Map<String, Object>> data = new ArrayList<Map<String, Object>>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);


        BottomNavigationView navigation = (BottomNavigationView) findViewById(R.id.navigation);
        navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);

        HashMap<String, Object> params = new HashMap<String, Object>();
        params.put("password", "15559867607");
        params.put("accounts", "aaaaaaaaaaaaaaaaaaas");
        params.put("siteName", "百度");
        data.add(params);

        params = new HashMap<String, Object>();
        params.put("password", "aaa2");
        params.put("accounts", "cccc");
        params.put("siteName", "新浪");
        data.add(params);


        AccountsListAdapter adapter1 = new AccountsListAdapter(MainActivity.this, data);
        getListView().setAdapter(adapter1);
    }

    private ListView getListView() {
        ListView listView = (ListView) findViewById(R.id.accounts_list);
        return listView;
    }

}
